/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "PRECIO_HISTORIAL")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PrecioHistorial.findAll", query = "SELECT p FROM PrecioHistorial p"),
    @NamedQuery(name = "PrecioHistorial.findByModCod", query = "SELECT p FROM PrecioHistorial p WHERE p.precioHistorialPK.modCod = :modCod"),
    @NamedQuery(name = "PrecioHistorial.findByAlutCod", query = "SELECT p FROM PrecioHistorial p WHERE p.precioHistorialPK.alutCod = :alutCod"),
    @NamedQuery(name = "PrecioHistorial.findByPrecCod", query = "SELECT p FROM PrecioHistorial p WHERE p.precioHistorialPK.precCod = :precCod"),
    @NamedQuery(name = "PrecioHistorial.findByPrehFech", query = "SELECT p FROM PrecioHistorial p WHERE p.precioHistorialPK.prehFech = :prehFech"),
    @NamedQuery(name = "PrecioHistorial.findByPrehMont", query = "SELECT p FROM PrecioHistorial p WHERE p.prehMont = :prehMont")})
public class PrecioHistorial implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PrecioHistorialPK precioHistorialPK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "PREH_MONT")
    private Double prehMont;
    @JoinColumns({
        @JoinColumn(name = "MOD_COD", referencedColumnName = "MOD_COD", insertable = false, updatable = false),
        @JoinColumn(name = "ALUT_COD", referencedColumnName = "ALUT_COD", insertable = false, updatable = false),
        @JoinColumn(name = "PREC_COD", referencedColumnName = "PREC_COD", insertable = false, updatable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Precio precio;

    public PrecioHistorial() {
    }

    public PrecioHistorial(PrecioHistorialPK precioHistorialPK) {
        this.precioHistorialPK = precioHistorialPK;
    }

    public PrecioHistorial(int modCod, int alutCod, int precCod, Date prehFech) {
        this.precioHistorialPK = new PrecioHistorialPK(modCod, alutCod, precCod, prehFech);
    }

    public PrecioHistorialPK getPrecioHistorialPK() {
        return precioHistorialPK;
    }

    public void setPrecioHistorialPK(PrecioHistorialPK precioHistorialPK) {
        this.precioHistorialPK = precioHistorialPK;
    }

    public Double getPrehMont() {
        return prehMont;
    }

    public void setPrehMont(Double prehMont) {
        this.prehMont = prehMont;
    }

    public Precio getPrecio() {
        return precio;
    }

    public void setPrecio(Precio precio) {
        this.precio = precio;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (precioHistorialPK != null ? precioHistorialPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PrecioHistorial)) {
            return false;
        }
        PrecioHistorial other = (PrecioHistorial) object;
        if ((this.precioHistorialPK == null && other.precioHistorialPK != null) || (this.precioHistorialPK != null && !this.precioHistorialPK.equals(other.precioHistorialPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.PrecioHistorial[ precioHistorialPK=" + precioHistorialPK + " ]";
    }
    
}
